package com.dd.ms.auth.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dd.ms.auth.mapper.RolePermissionRelMapper;
import com.dd.ms.auth.mapper.UserRolesRelMapper;
import com.dd.ms.auth.pojo.DO.RoleDO;
import com.dd.ms.auth.pojo.DO.UserRolesRelDO;
import com.dd.ms.auth.pojo.req.RolePersBatchAddReq;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/7/9 16:00
 * @Description 角色 & 权限 关联操作 仓储层
 */
@Repository
@RequiredArgsConstructor
public class UserRolesRelRepository {

    private final UserRolesRelMapper userRolesRelMapper;

    public void batchAddUserRoles(Long userId, List<Long> roleIds) {
        userRolesRelMapper.batchAddUserRoles(userId, roleIds);
    };

    public List<RoleDO> getRolesByUserId(Long userId) {
        return userRolesRelMapper.getRolesByUserId(userId);
    }

    public void add(UserRolesRelDO rel) {
        userRolesRelMapper.insert(rel);
    }
}
